﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace TaskDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            var task =Task.Run(() =>
            {
                Thread.Sleep(2000);
                Console.WriteLine("foooooooo");
            });
            Console.WriteLine(task.IsCompleted);
            task.Wait();
            Console.WriteLine("所有线程执行完成");


            //长时间计算(不使用线程池)例子:
            Task task1 = Task.Factory.StartNew(() => {
                Thread.Sleep(3000);
            },TaskCreationOptions.LongRunning);

        }
    }
}
